package cn.chencaiju.day02;

public class ArrayTest4 {
	public static void main(String[] args) {
		int[] numbers1 = { 8, 9, 9, 9, 9, 8 };
		int[] numbers2 = { 8, 9, 9, 9, 8 };
		int[] numbers3 = { 1, 2, 3, 4, 5, 6, 6, 6, 7, 7, 7, 7 };
		System.out.println(hasContinuousFour(numbers1));
		System.out.println(hasContinuousFour(numbers2));
		System.out.println(hasContinuousFour(numbers3));
	}

	public static boolean hasContinuousFour(int[] numbers) {
		int flag = 1;
		int end = numbers.length;
		for (int i = 0; i < end - 1; i++) {
			if (numbers[i] == numbers[i + 1]) {
				flag++;
				if (flag >= 4) {
					return true;
				}
			} else {
				flag = 1;
			}
		}
		return false;
	}
}
